package com.controller;


import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Controller
@RequestMapping(value="/user")
public class UserController {

    private static Logger logger = Logger.getLogger(UserController.class);

//    @Autowired
//    private UserService userService;

    @RequestMapping(value="/list")
    public String list(HttpServletRequest request, Model model) throws Exception{
        return "user/user_list";
    }

//    @ResponseBody
//    @RequestMapping(value="/listJson")
//    public DataGrid listJson(HttpServletRequest request, Model model) throws Exception{
//        String abv= request.getParameter("page");
//        List<User> list = userService.getUserList(null);
//        DataGrid dg = new DataGrid();
//        dg.setCode(0);
//        dg.setCount(50);
//        dg.setData(list);
//        dg.setMsg("");
//        return dg;
//    }
//    @RequestMapping(value="/toAdd")
//    public String toAdd(HttpServletRequest request, Model model) throws Exception{
//        return "user/user_add";
//    }

//    @RequestMapping(value="/add")
//    public String add(HttpServletRequest request, Model model) throws Exception{
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:ss:mm");
//        String name = request.getParameter("name");
//        User user  = new User();
//        user.setName(name);
//        user.setUpdateTime(sdf.format(new Date()));
//
//        UserDetail userDetail = new UserDetail();
//        String age = request.getParameter("age");
//        userDetail.setAge(Integer.parseInt(age));
//        String gender = request.getParameter("gender");
//        userDetail.setGender(gender);
//        userService.addUser(user,userDetail);
//        return "redirect:/user/list.html";
//    }
}
